package com.liu.netty.controller;

import com.liu.common.entity.Result;
import com.liu.netty.server.ClientsMap;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2019/8/29 0029.
 */
@RequestMapping("/client")
@RestController
public class ClientsController {

    @GetMapping
    public Map getClients(){
     return  ClientsMap.getAllClients();
    }

    @PostMapping("/send/{id}")
    public Result sendMsg(@PathVariable String id, String msg){


          ClientsMap.getChannel(id).writeAndFlush(msg);


      return  new Result(true,111,"消息发送成功");
    }

    @PostMapping("/update/{id}")
    public Result updateDriverConfig(@PathVariable String id,@RequestBody Map param){
        ClientsMap.getChannel(id).writeAndFlush(param);

        return  new Result(true,1,"设备参数修改成功！！");
    }
}
